/*
  @author NormanMises
  @date 2023/6/10 - 18:50
*/

package com.example.demo.service.impl.user.account;

import com.example.demo.pojo.user;
import com.example.demo.service.impl.utils.UserDetaileImpl;
import com.example.demo.service.user.account.InfoService;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.*;
@Service
public class InfoServiceImpl implements InfoService {
    @Override
    public Map<String, String> getinfo() {
        UsernamePasswordAuthenticationToken authentication=(UsernamePasswordAuthenticationToken)
                SecurityContextHolder.getContext().getAuthentication();
        UserDetaileImpl loginusers = (UserDetaileImpl) authentication.getPrincipal();
        user user=loginusers.getUser();
        Map<String,String> map= new HashMap<>();
        map.put("message","success");
        map.put("id:", user.getId().toString());
        map.put("name:", user.getUsername());
        map.put("password:",user.getPassword());
        System.out.println(map);
        return map;
    }
}
